package com.tiyende.kash.loop.ui.dialog

import android.content.Context
import android.graphics.Paint
import android.view.LayoutInflater
import android.view.View
import com.tiyende.kash.loop.R
import com.tiyende.kash.loop.common.CommonDialog
import com.tiyende.kash.loop.databinding.TiyendeDialogAccountSubmitOnlyOneTipsBinding
import com.tiyende.kash.loop.event.TiyendeEventPointType

/**
 * TiyendeCredit
 * @Author wwdeng
 * @CreateTime: 2024/11/21 13:45
 * @Annotation：提交只有一个收款账户提示dialog
 */
class TiyendeAccountSubmitOnlyOneDialog: CommonDialog {
    private lateinit var binding: TiyendeDialogAccountSubmitOnlyOneTipsBinding
    private var mCallback: IDialogCallback? = null
    //事件备注
    private var eventRemark = ""

    constructor(context: Context) : super(context) {}
    constructor(context: Context, callback: IDialogCallback?) : super(context) {
        mCallback = callback
    }

    constructor(context: Context, remark: String,callback: IDialogCallback?) : super(context) {
        mCallback = callback
        eventRemark = remark
    }

    /**
     * 设置点击回调
     */
    fun setOnClick(callback: IDialogCallback){
        this.mCallback = callback
    }

    override fun getTiyendeRootView(): View {
        binding = TiyendeDialogAccountSubmitOnlyOneTipsBinding.inflate(LayoutInflater.from(context))
        return binding.root
    }

    override fun initTiyendeView() {
        binding.walletWarningNoMore.paint.flags = Paint.UNDERLINE_TEXT_FLAG//下划线
        binding.walletWarningNoMore.paint.isAntiAlias = true//抗锯齿

    }

    override fun initTiyendeListener() {
        setOnClickListener(binding.walletWarningAdd) //继续添加
        setOnClickListener(binding.walletWarningNoMore) //没有更多
        setOnClickListener(binding.imageClose)//关闭
    }

    override fun loadTiyendeData() {
    }

    override fun onTiyendeViewClick(v: View?) {
        dismiss()
        when(v?.id){
            R.id.walletWarningNoMore -> {
                addEventPointRequestAction(TiyendeEventPointType.CLICK.TIYENDE_CLICK_USER_ACCOUNT_SUBMIT_ONLYONE_TIPS_CANCEL,eventRemark)
            }
            R.id.walletWarningAdd -> {
                addEventPointRequestAction(TiyendeEventPointType.CLICK.TIYENDE_CLICK_USER_ACCOUNT_SUBMIT_ONLYONE_TIPS_CONFIRM,eventRemark)
            }
        }
        mCallback?.onClick(v)
    }

    interface IDialogCallback {
        //按钮点击
        fun onClick(view: View?)
    }

    override fun onStart() {
        super.onStart()
        addEventPointRequestAction(TiyendeEventPointType.DIALOG.TIYENDE_DIALOG_USER_ACCOUNT_SUBMIT_ONLY_ONE_TIPS_SHOW,eventRemark)
    }

    override fun dismiss() {
        super.dismiss()
        addEventPointRequestAction(TiyendeEventPointType.DIALOG.TIYENDE_DIALOG_USER_ACCOUNT_SUBMIT_ONLY_ONE_TIPS_DISMISS,eventRemark)
    }
}